package com.ourteam.education.api;

import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;

import com.ourteam.education.dao.ClassDefineDAOQueryBean;
import com.ourteam.education.domain.ClassDefineBean;
import com.ourteam.frame.web.AbstractSearchModel;

public class ClassDefineSearchBean extends AbstractSearchModel<ClassDefineDAOQueryBean> {

	private Long[] campusId;

	private Long[] courseId;

	private Long[] classroomId;

	private String[] status;

	private String[] enrollmentStatus;

	private String className;

	public Long[] getCampusId() {
		return campusId;
	}

	public void setCampusId(Long[] campusId) {
		this.campusId = campusId;
	}

	public Long[] getCourseId() {
		return courseId;
	}

	public void setCourseId(Long[] courseId) {
		this.courseId = courseId;
	}

	public Long[] getClassroomId() {
		return classroomId;
	}

	public void setClassroomId(Long[] classroomId) {
		this.classroomId = classroomId;
	}

	public String getClassName() {
		return className;
	}

	public void setClassName(String className) {
		this.className = className;
	}

	public String[] getStatus() {
		return status;
	}

	public void setStatus(String[] status) {
		this.status = status;
	}

	public String[] getEnrollmentStatus() {
		return enrollmentStatus;
	}

	public void setEnrollmentStatus(String[] enrollmentStatus) {
		this.enrollmentStatus = enrollmentStatus;
	}

	@Override
	public String getMappedDAOField(String aProperty) {
		return ClassDefineBean.getMappedDAOField(aProperty);
	}

	@Override
	protected void doBuildQueryBean(ClassDefineDAOQueryBean queryBean) throws Exception {

		ClassDefineDAOQueryBean.Criteria criteria = queryBean.createCriteria();

		if (ArrayUtils.isNotEmpty(this.campusId)) {
			criteria.andCampusIdIn(campusId);
		}

		if (ArrayUtils.isNotEmpty(this.courseId)) {
			criteria.andCourseIdIn(courseId);
		}

		if (ArrayUtils.isNotEmpty(this.classroomId)) {
			criteria.andClassRoomIdIn(classroomId);
		}

		if (ArrayUtils.isNotEmpty(this.status)) {
			criteria.andStatusIn(status);
		}

		if (ArrayUtils.isNotEmpty(this.enrollmentStatus)) {
			criteria.andEnrollmentStatusIn(enrollmentStatus);
		}

		if (StringUtils.isNoneBlank(this.className)) {
			criteria.andClassNameLike(className);
		}
	}

}
